//
//  CustomerCardOwner.m
//  HuoBao
//
//  Created by sky on 15/11/30.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "CustomerCardOwner.h"
@interface CustomerCardOwner ()


@property (nonatomic, strong) void(^CancelAction)();
@property (nonatomic, strong) UIView *dangban;
@property (nonatomic, strong) UIView *bgview;


@end
@implementation CustomerCardOwner

- (instancetype)initCardOwner{
    self = [super init];
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    
    self.dangban = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.dangban.backgroundColor = [UIColor blackColor];
    self.dangban.alpha = 0.3;
    [self addSubview:self.dangban];
    
    
    self.bgview = [[UIView alloc]initWithFrame:CGRectMake(35, SCREEN_HEIGHT/2 - 336/4 - 50, SCREEN_WIDTH - 70, 444/2 - 26)];
    self.bgview.backgroundColor = [LCCommon getColor:@"3d3e41"];
    self.bgview.alpha = 0;
    self.bgview.layer.cornerRadius = 4;
    [self addSubview:self.bgview];
    
    UILabel *titile = [self LabelWithRect:CGRectMake(0, 56/2,self.bgview.width, 22) textColor:[LCCommon getColor:@"ffffff"] textstr:@"持卡人说明" textfont:22 textstyle:NSTextAlignmentCenter];
    [self.bgview addSubview:titile];
    
    
    UILabel *safe = [self LabelWithRect:CGRectMake(0, titile.origin.y + 22 + 54/2, self.bgview.width , 13) textColor:[LCCommon getColor:@"b1b1b1"] textstr:@"为了您的账号资金安全" textfont:13 textstyle:NSTextAlignmentCenter];
    [self.bgview addSubview:safe];
    
    
    UILabel *only = [self LabelWithRect: CGRectMake(0, safe.origin.y + 13 + 9/2, safe.size.width, 13) textColor:[LCCommon getColor:@"b1b1b1"] textstr:@"只能绑定持卡人本人的银行卡" textfont:13 textstyle:NSTextAlignmentCenter];
    [self.bgview addSubview:only];
    
    
//    UILabel *help = [self LabelWithRect: CGRectMake(0, only.origin.y + 13 + 36/2, only.size.width, 13) textColor:[LCCommon getColor:@"b1b1b1"] textstr:@"获取更多帮助,请致电金信客服" textfont:13 textstyle:NSTextAlignmentCenter];
//    [self.bgview addSubview:help];
//    
//    
//    UILabel *phonenum = [self LabelWithRect:CGRectMake(0, help.origin.y + 13 + 28/2, help.size.width, 13) textColor:[LCCommon getColor:@"289fe4"] textstr:@"0755-86010333" textfont:13 textstyle:NSTextAlignmentCenter];
//    [self.bgview addSubview:phonenum];
    
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, self.bgview.height - 45.5, self.bgview.width, .5)];
    line.backgroundColor = [LCCommon getColor:@"696969"];
    [self.bgview addSubview:line];
    
    
    UIButton *xiaodei = [[UIButton alloc]initWithFrame:CGRectMake(0, self.bgview.height - 45, line.size.width, 45)];
    [xiaodei setTitle:@"知道了" forState:UIControlStateNormal];
    [xiaodei setTitleColor:[LCCommon getColor:@"ffffff"] forState:UIControlStateNormal];
    xiaodei.titleLabel.font = [UIFont systemFontOfSize:16];
    [xiaodei addTarget:self action:@selector(cancelBtnTap) forControlEvents:UIControlEventTouchUpInside];
    xiaodei.backgroundColor = [UIColor clearColor];
    [self.bgview addSubview:xiaodei];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(cancelBtnTap)];
    [self.dangban addGestureRecognizer:tap];
    
    return self;
}


-(UILabel *)LabelWithRect:(CGRect)rect textColor:(UIColor *)color textstr:(NSString *)str textfont:(int)font textstyle:(NSTextAlignment)aligment{
    UILabel *label = [[UILabel alloc] initWithFrame:rect];
    label.textColor = color;
    label.text = str;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = aligment;
    label.numberOfLines = 0;
    return label;
}



- (void)showInView
{
    
    [UIView animateWithDuration:0.25 animations:^{
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        [[UIApplication sharedApplication].keyWindow addSubview:self];
        self.bgview.backgroundColor = [LCCommon getColor:@"3d3e41"];
        self.bgview.alpha = 1;
    }completion:^(BOOL finished) {
        
    }];
}

- (void)cancelBtnTap
{
    if (self.CancelAction)
    {
        self.CancelAction();
    }
    [self dismiss];
}

- (void)dismiss
{
    self.CancelAction = nil;
    [self removeFromSuperview];
}


@end
